/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package lib;

import java.awt.Dimension;
import java.awt.Toolkit;

/**
 *
 * @author gluo
 */
public class Utils {
    
    public static boolean valid_discount(String s) {
        try {
            float f = Float.parseFloat(s);
        }
        catch (Exception e) {
            return false;
        }
        return true;
    }

    public static boolean valid_keywords(String s) {
        if (s.length() < 1) {
            return false;
        }
        else return true;
    }
    
    public static boolean valid_price(String s) {
        try {
            float f = Float.parseFloat(s);
            if (f <= 0) return false;
        }
        catch (Exception e) {
            return false;
        }
        return true;
    }

    public static void p(Object s) {
        System.out.println(s);
    }
    
    public static void pf(String fmt, Object s) {
        System.out.printf(fmt, s);
    }
    
    public static int get_scr_height(){
        Dimension scrSize=Toolkit.getDefaultToolkit().getScreenSize();
        return scrSize.height;
    }
    
    public static int get_scr_width(){
        Dimension scrSize=Toolkit.getDefaultToolkit().getScreenSize();
        return scrSize.width;
    }
    
    public static void main(String args[]) {
        pf("%.2f", 2.323235);
    }

}
